home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.preinst < prev    next >
Encoding:
Text File  |  2007-04-04  |  9.0 KB  |  284 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. if [ "$1" = upgrade ]
  6. then
  7.     if dpkg --compare-versions "$2" le 2.2.2-4 && test -e /lib/libdb.so.3; then
  8.     # Make upgrades to newer libdb.so.3 easier
  9.     cat /lib/libdb.so.3 > /lib/libdb.so.3.old
  10.     fi
  11.     if dpkg --compare-versions "$2" le 2.1.1-0.1; then
  12.     if [ -f /var/run/utmpd.pid ]; then
  13.         if kill -s TERM `cat /var/run/utmpd.pid` > /dev/null 2>&1
  14.         then
  15.         if [ -f /var/run/utmp ]; then
  16.             cp /dev/null /var/run/utmp
  17.             if grep '^utmp:' /etc/group; then
  18.             chown root:utmp /var/run/utmp
  19.             chmod 664 /var/run/utmp
  20.             else
  21.             chown root:root /var/run/utmp
  22.             chmod 644 /var/run/utmp
  23.             fi
  24.         fi
  25.         if [ -f /var/log/wtmp ]; then
  26.             savelog /var/log/wtmp
  27.             touch /var/log/wtmp
  28.             if grep '^utmp:' /etc/group; then
  29.             chown root:utmp /var/log/wtmp
  30.             chmod 664 /var/log/wtmp
  31.             else
  32.             chown root:root /var/log/wtmp
  33.             chmod 644 /var/log/wtmp
  34.             fi
  35.         fi
  36.         rm -f /etc/init.d/utmpd
  37.         update-rc.d utmpd remove > /dev/null
  38.         fi
  39.     fi
  40.     if [ -f /var/run/utmpx ]; then rm -f /var/run/utmpx; fi
  41.     if [ -f /var/log/wtmpx ]; then rm -f /var/log/wtmpx*; fi
  42.     if [ -e /var/run/utmpd.ro ]; then rm -f /var/run/utmpd.ro; fi
  43.     if [ -e /var/run/utmpd.rw ]; then rm -f /var/run/utmpd.rw; fi
  44.     fi
  45.  
  46.     # NSS authentication trouble guard
  47.     if dpkg --compare-versions $2 lt 2.3.5-1; then
  48.     check="xdm kdm gdm postgresql xscreensaver"
  49.     # Only get the ones that are installed, and configured
  50.     service=$(dpkg -s $check 2> /dev/null | awk 'BEGIN{RS="\n\n";FS="\n"}{if ( $2 ~ /Status: .* installed$/ ) { print $1 } }' | cut -f 2 -d ' ')
  51.  
  52.     echo
  53.     echo "Name Service Switch update in the C Library: pre-installation question."
  54.     echo
  55.     echo "Running services and programs that are using NSS need to be restarted,"
  56.     echo "otherwise they might not be able to do lookup or authentication any more."
  57.     echo "The installation process is able to restart some services (such as ssh or"
  58.     echo "telnetd), but other programs cannot be restarted automatically.  One such"
  59.     echo "program that needs manual stopping and restart after the glibc upgrade by"
  60.     echo "yourself is xdm - because automatic restart might disconnect your active"
  61.     echo "X11 sessions."
  62.     echo
  63.     echo "Known packages that need to be stopped before the glibc upgrade are:"
  64.     echo "        $check"
  65.     echo
  66.  
  67.     if [ -n "$service" ]; then 
  68.         echo "This script detected the following installed services which must be"
  69.         echo "stopped before the upgrade:"
  70.         echo "        $service"
  71.     else
  72.         echo "This script did not detect any installed services which need to be"
  73.         echo "stopped."
  74.     fi
  75.     echo
  76.     echo "If you want to interrupt the upgrade now and continue later, please"
  77.     echo "answer No to the question below."
  78.     echo 
  79.     frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  80.     if [ "$frontend" = noninteractive ]; then
  81.         echo "Non-interactive mode, upgrade glibc forcibly"
  82.         answer=yes
  83.     else
  84.         echo -n "Do you want to upgrade glibc now? [Y/n] "
  85.         read answer
  86.         case $answer in
  87.         Y*|y*) answer=yes ;;
  88.         N*|n*) answer=no ;;
  89.         *) answer=yes ;;
  90.         esac
  91.     fi
  92.     echo
  93.     if [ "$answer" = no ]; then
  94.         echo "Stopped glibc upgrade.  Please retry the upgrade after you have"
  95.         echo "checked or stopped services by hand."
  96.         exit 1
  97.     fi
  98.     fi
  99.  
  100.     # This will keep us from using hwcap libs (optimized) during an
  101.     # upgrade.
  102.     touch /etc/ld.so.nohwcap
  103.     echo glibc >> /etc/ld.so.nohwcap
  104. fi
  105.  
  106. # Sanity check.
  107. # If there are versions of glibc outside of the normal installation
  108. # location (/lib, /lib64, etc.) then things may break very badly
  109. # as soon as ld.so is replaced by a new version.  This check is not
  110. # foolproof, but it's pretty accurate.  This script ignores libraries
  111. # with different sonames, and libraries incompatible with the 
  112. # to-be-installed ld.so.
  113.  
  114. check_dirs () {
  115.   for dir in $*; do
  116.     # Follow symlinks
  117.     dirlink=$(readlink -f $dir)
  118.     [ -n "$dirlink" ] && dir=$dirlink 
  119.     
  120.     # Handle /lib in LD_LIBRARY_PATH.
  121.     if expr $dir : "/lib.*" > /dev/null; then
  122.       continue
  123.     fi
  124.     # Skip ia32-libs package on ia64, and similar libraries
  125.     # (not sure why these get added to /etc/ld.so.conf)
  126.     if expr $dir : "/emul/.*" > /dev/null; then
  127.       continue
  128.     fi
  129.     if test -d $dir; then
  130.       output=$(ls $dir | egrep '^(libc.so.6|libm.so.6|libpthread.so.0|librt.so.1|libdl.so.2)$' 2>/dev/null)
  131.  
  132.       if test -n "$output"; then
  133.     # See if the found libraries are compatible with the system ld.so;
  134.     # if they aren't, they'll be ignored.  Check e_ident, e_type (which
  135.     # will just be ET_DYN), and e_machine.  If a match is found, there
  136.     # is a risk of breakage.
  137.     for lib in $output
  138.     do
  139.       if test -f "$dir/$lib"; then
  140.         libbytes=`head -c 20 $dir/$lib | od -c`
  141.         if test "$ldbytes" = "$libbytes"; then
  142.           echo "Matching libraries: $dir/$lib"
  143.           return 0
  144.         fi
  145.       fi
  146.     done
  147.       fi
  148.     fi
  149.   done
  150.   return 1
  151. }
  152.  
  153. if [ "$1" != abort-upgrade ]
  154. then
  155.   ldbytes=`head -c 20 /lib/ld-linux.so.2 | od -c`
  156.   dirs="/lib32 /lib64 /usr/local/lib /usr/local/lib32 /usr/local/lib64"
  157.   if ! test -L /usr; then
  158.     dirs="$dirs /usr/lib /usr/lib32 /usr/lib64"
  159.   fi
  160.   if check_dirs $dirs; then
  161.     echo
  162.     echo "A copy of glibc was found in an unexpected directory."
  163.     echo "It is not safe to upgrade the C library in this situation;"
  164.     echo "please remove that copy of the C library and try again."
  165.     echo "Please check: https://launchpad.net/bugs/81125"
  166. #    exit 1
  167.   fi
  168.  
  169.   if test -n "$LD_LIBRARY_PATH"; then
  170.     dirs=$(echo $LD_LIBRARY_PATH | sed 's/:/ /')
  171.     if check_dirs $dirs; then
  172.       echo
  173.       echo "Another copy of the C library was found via LD_LIBRARY_PATH."
  174.       echo "It is not safe to upgrade the C library in this situation;"
  175.       echo "please remove the directory from LD_LIBRARY_PATH and try again."
  176.       echo "Please check: https://launchpad.net/bugs/81125"
  177. #      exit 1
  178.     fi
  179.   fi
  180.   if test -e /etc/ld.so.conf; then
  181.     dirs=$(echo $(cat /etc/ld.so.conf))
  182.     if check_dirs $dirs; then
  183.       echo
  184.       echo "Another copy of the C library was found via /etc/ld.so.conf."
  185.       echo "It is not safe to upgrade the C library in this situation;"
  186.       echo "please remove the directory from /etc/ld.so.conf and try again."
  187.       echo "Please check: https://launchpad.net/bugs/81125"
  188. #      exit 1
  189.     fi
  190.   fi
  191. fi
  192.  
  193. if [ "$1" != abort-upgrade ] && [ "`uname -s`" = Linux ]
  194. then
  195.     # glibc kernel version check: KERNEL_VERSION_CHECK
  196. kernel_compare_versions () {
  197.     verA=$(($(echo "$1" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  198.     verB=$(($(echo "$3" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 10000 + \2 \* 100 + \3/')))
  199.     
  200.     test $verA -$2 $verB
  201. }
  202.  
  203. exit_check () {
  204.     
  205.     exit 1
  206. }
  207.  
  208.     # Test to make sure z < 255, in x.y.z-n form of kernel version
  209.     # Also make sure we don't trip on x.y.zFOO-n form
  210.     #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
  211.     kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
  212.     if [ "$kernel_rev" -ge 255 ]
  213.     then
  214.         echo WARNING: Your kernel version indicates a revision number
  215.         echo of 255 or greater.  Glibc has a number of built in
  216.         echo assumptions that this revision number is less than 255.
  217.         echo If you\'ve built your own kernel, please make sure that any 
  218.         echo custom version numbers are appended to the upstream
  219.         echo kernel number with a dash or some other delimiter.
  220.  
  221.         exit_check
  222.     fi
  223.  
  224.     # sanity checking for the appropriate kernel on each architecture.
  225.     realarch=`uname -m`
  226.     kernel_ver=`uname -r`
  227.  
  228.     # convert "armv4l" and similar to just "arm", and "mips64" and similar
  229.     # to just "mips"
  230.     case $realarch in
  231.       arm*) realarch="arm";;
  232.       mips*) realarch="mips";;
  233.     esac
  234.     
  235.  
  236.     # intel i386 requires a recent kernel
  237.     if [ "$realarch" = i386 ]
  238.     then
  239.     # From glibc 2.3.5-7 and linux-2.6 2.6.12-1, real-i386 is dropped.
  240.     #if kernel_compare_versions "$kernel_ver" lt 2.4.24
  241.     #then
  242.         echo WARNING: This machine has real i386 class processor.
  243.         echo Debian etch and later does not support such old hardware
  244.         echo any longer.
  245.         echo The reason is that \"bswap\" instruction is not supported
  246.         echo on i386 class processors, and some core libraries have 
  247.         echo such instruction.  You\'ll see illegal instruction error
  248.         echo when you upgrade your Debian system.
  249.         exit_check
  250.     #fi
  251.     fi
  252.  
  253.     # The GNU libc requires 2.6 kernel (except on m68k) because we drop to 
  254.     # support linuxthreads
  255.     if [ "$realarch" != m68k ]
  256.     then
  257.     if kernel_compare_versions "$kernel_ver" lt 2.6.0
  258.     then
  259.         echo WARNING: POSIX threads library NPTL requires 2.6 and
  260.         echo later kernel.  If you use 2.4 kernel, please upgrade your
  261.         echo kernel before installing glibc.
  262.         exit_check
  263.     fi
  264.     fi
  265.     
  266.     # The GNU libc is now built with --with-kernel= >= 2.4.1 on m68k
  267.     if [ "$realarch" = m68k ]
  268.     then
  269.     if kernel_compare_versions "$kernel_ver" lt 2.4.1
  270.     then
  271.         echo WARNING: This version of glibc requires that you be running
  272.         echo kernel version 2.4.1 or later.  Earlier kernels contained
  273.         echo bugs that may render the system unusable if a modern version
  274.         echo of glibc is installed.
  275.         exit_check
  276.     fi
  277.     fi
  278.  
  279. fi
  280.  
  281.  
  282.  
  283. exit 0
  284.